package com.jjb.www.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.hjq.shape.view.ShapeTextView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.MineMessageApi;

/**
 *    author : Android CRG
 *    time   : 2018/11/05
 *    desc   : 消息adapter
 */
public final class MineMesageAdapter extends AppAdapter<MineMessageApi.Bean> {

    public MineMesageAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeTextView mTvTime;
        private ShapeTextView mTvContent;
        private ShapeTextView mTvType;



        private ViewHolder() {
            super(R.layout.item_mine_message);
            mTvTime = findViewById(R.id.tv_time);
            mTvContent = findViewById(R.id.tv_content);
            mTvType = findViewById(R.id.tv_type);
        }

        @Override
        public void onBindView(int position) {
            MineMessageApi.Bean bean = getItem(position);
            mTvTime.setText(bean.getSend_time());
            mTvContent.setText(bean.getTitle());
            if (bean.getMessage_type()==1){
                mTvType.setText("系统通知");
            }else {
                mTvType.setText("推送消息");
            }
        }
    }
}